﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ExpressionMapper.Tests
{
    [TestClass]
    public class StringConvertionTests
    {
        [TestMethod]
        public void ConvertPrimitiveToString()
        {
            var m = Mapper.Create<int, string>();
            Assert.AreEqual("1", m(1));
        }

        [TestMethod]
        public void ConvertStringToPrimitive()
        {
            var m = Mapper.Create<string, int>();
            Assert.AreEqual(1, m("1"));            
        }

        [TestMethod]
        public void ConvertNullStringToPrimitive()
        {
            var m = Mapper.Create<string, int>();
            Assert.AreEqual(0, m(null));
        }

        [TestMethod]
        public void ConvertEmptyString()
        {
            var m = Mapper.Create<string, DateTime>();
            DateTime dt = new DateTime(2012, 12, 12);
            // add value info to an exception
            Assert.AreEqual(dt, m(string.Empty));
        }

        [TestMethod]
        public void ConvertStringToDateTime()
        {
            var m = Mapper.Create<string, DateTime>();
            DateTime dt = new DateTime(2012,12,12);
            Assert.AreEqual(dt, m("12.12.2012"));
        }
    }
}
